# 設置配置類
from datetime import timedelta
from redis import StrictRedis
import logging

class Config(object):
    # 祕鑰
    SECRET_KEY = "fjkdjfkdjfkdjkfjkdjfkdjfkdjfkd"
    DEBUG = True
    # 數據庫配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/ihome"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # SQLALCHEMY_COMMIT_ON_TEARDOWN = True  # 当视图函数结束之后,自动提交

    # 配置redis
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 配置session信息
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)  # session保存的时间2天

    # 默認的日志級別
    LEVEL = logging.DEBUG

    # 七牛云的访问服务器
    QINIU_URL = "http://pr18q2u40.bkt.clouddn.com/"



# 開發環境
class DevelopConfig(Config):
    pass


# 生產環境（線上環境）
class ProductConfig(Config):
    DEBUG = False
    LEVEL = logging.ERROR


# 測試環境
class TestingConfig(Config):
    TESTING = True


# 提供一個容器（字典）去管理所有的配置類
config_dict = {
    "develop": DevelopConfig,
    "product": ProductConfig,
    "testing": TestingConfig
}
